﻿
<!--_meta 作为公共模版分离出去-->
{include file="public/_meta"}

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 捐赠管理 <span class="c-gray en">&gt;</span> 捐赠列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form action="" method="get">
	<div class="text-c">
		<input type="text" class="input-text" style="width:250px" placeholder="输入书籍名称" id="" name="keywords">
		<button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜书名</button>
	</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="dataDel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;" onclick="add_donation('添加捐赠','{:url(\'donation/add_donation\')}','800','400')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加捐赠</a>
			<a href="{:url('donation/export_donation_excel')}" class="btn btn-primary radius">
				<i class="Hui-iconfont">&#xe644;</i> 导出excel
			</a>
		</span>
		<span class="r">共有数据：<strong>{$count}</strong> 条</span> </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th>ID</th>
				<th>捐赠人姓名</th>
				<th>书籍名称</th>
				<th>书籍价格</th>
				<th>所获学币</th>
				<th>募捐人姓名</th>
				<th>捐赠时间</th>
				<th>学币领取</th>
				<th>书籍接收</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			{volist name="donation_list" id="vo"}
			<tr class="text-c">
				<td><input class="checkbox" type="checkbox" value="{$vo.did}" name="id[]"></td>
				<td>{$vo.did}</td>
				<td><a href="javascript:void(0);" style="cursor:pointer" class="text-primary" onclick="student_show('{$vo.full_name}','{:url(\'student/student_show\')}?id={$vo.uid}','{$vo.uid}','500','450')"><u><b>{$vo.full_name}</b></u></a></td>
				<td><a href="javascript:void(0);" style="cursor:pointer" class="text-primary" onclick="donation_show('{$vo.donation_book}','{:url(\'donation/donation_show\')}?id={$vo.did}','{$vo.did}','500','450')"><u><b>{$vo.donation_book}</b></u></a></td>
				<td>{$vo.donation_price}</td>
				<td>{$vo.get_coin}</td>

				{if condition="$vo.donation_collect_id eq 1"}
					<td><a href="javascript:void(0);" style="cursor:pointer" class="text-primary" onclick="member_show('{$vo.full_name}','{:url(\'member/member_show\')}?id={$vo.donation_collect_id}','{$vo.uid}','500','450')"><u><b>{$vo.collect_name}</b></u></a></td>
				{else/}
					<td><a href="javascript:void(0);" style="cursor:pointer" class="text-primary" onclick="student_show('{$vo.full_name}','{:url(\'student/student_show\')}?id={$vo.donation_collect_id}','{$vo.uid}','500','450')"><u><b>{$vo.collect_name}</b></u></a></td>
				{/if}

				<td>{$vo.donation_time|date="Y-m-d H:i:s",###}</td>
				<td class="td-status">
					{if condition="$vo.is_receive eq 1"}
					<span class="label label-success radius">已领取</span>
					{else/}
					<span class="label label-default radius">未领取</span>
					{/if}
				</td>
				<td class="td-status">
					{if condition="$vo.submit_status eq 1"}
						<span class="label label-success radius">成功移交</span>
					{elseif condition="$vo.submit_status eq 0"}
						<span class="label label-default  radius">尚未移交</span>
					{elseif condition="$vo.submit_status eq 2"}
						<span class="label label-warning radius">书籍退回</span>
					{/if}
				</td>
				<td class="td-manage">
					<a title="编辑" href="javascript:;" onclick="donation_edit('编辑','{:url(\'donation/edit_donation\')}?id={$vo.did}','{$vo.did}','800','400')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a style="text-decoration:none" class="ml-5" onClick="book_receive(this,'{$vo.did}')" href="javascript:;" title="确认接收"><i class="Hui-iconfont">&#xe6de;</i></a>
					<a style="text-decoration:none" class="ml-5" onClick="book_return(this,'{$vo.did}')" href="javascript:;" title="确认退回"><i class="Hui-iconfont">&#xe6dc;</i></a>
					<a title="删除" href="javascript:;" onclick="del_donation(this,'{$vo.did}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
			</tr>
			{/volist}
		</tbody>
	</table>
	</div>
</div>

<!--_footer 作为公共模版分离出去-->
{include file="public/_footer"}


<script type="text/javascript">
$(function(){
	$('.table-sort').dataTable({
		"aaSorting": [[ 1, "asc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
			//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
			{"orderable":false,"aTargets":[0,10]}// 制定列不参与排序
		]
	});

});
/*用户-捐赠书籍*/
function add_donation(title,url,w,h){
	layer_show(title,url,w,h);
}
/*学生-查看*/
function student_show(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*学生-查看*/
function member_show(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*用户-捐赠书籍详情*/
function donation_show(title,url,id,w,h){
	layer_show(title,url,w,h);
}

//书籍回收
function book_receive(obj,id){
    layer.confirm('要确认收取吗？',function(index){
        $.ajax({
            type: 'post',
            url: "{:url('donation/book_receive')}",
            dataType: 'json',
            data: {id:id},
            success: function(rec){
                if(rec.status == true){
                    layer.msg(rec.message,{icon:1,time:1000});
                    setTimeout(jump,1000);
                    function jump(){
                        window.location.replace(location.href);
                    }
                }else if(rec.status == false){
                    layer.msg(rec.message,{icon:5,time:1000});
                }
            }
        });
    });
}

//书籍退还
function book_return(obj,id){
    layer.confirm('要确认退还吗？',function(index){
        $.ajax({
            type: 'post',
            url: "{:url('donation/book_return')}",
            dataType: 'json',
            data: {id:id},
            success: function(rec){
                if(rec.status == true){
                    layer.msg(rec.message,{icon:1,time:1000});
                    setTimeout(jump,1000);
                    function jump(){
                        window.location.replace(location.href);
                    }
                }else if(rec.status == false){
                    layer.msg(rec.message,{icon:5,time:1000});
                }
            },
            error:function(rec) {
                console.log(rec.msg);
            }
        });
    });
}

/*捐赠-编辑*/
function donation_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}

/*捐赠-删除*/
function del_donation(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'post',
			url: "{:url('donation/del_donation')}",
			dataType: 'json',
			data: {id:id},
			success: function(rec){
				if(rec.status == true){
					$(obj).parents("tr").remove();
					layer.msg(rec.message,{icon:1,time:1000});
				}else if(rec.status == false){
					layer.msg(rec.message,{icon:5,time:1000});
				}
			},
			error:function(rec) {
				console.log(rec.msg);
			}
		});		
	});
}
//批量删除
function dataDel(){
	layer.confirm('确认要删除吗？',function(index){
		var donation_id =[];
		$('input[name="id[]"]:checked').each(function(){
			donation_id.push($(this).val());
		});
		$.ajax({
			type: 'post',
			url: "{:url('donation/batch_del_donation')}",
			dataType: 'json',
			data: {id:donation_id},
			success: function(rec){
				if(rec.status == true){
					layer.msg(rec.message,{icon:6,time:1000});
					setTimeout(jump,1000);
					function jump(){
						window.location.replace(location.href);
					}
				}else if(rec.status == false){
					layer.msg(rec.message,{icon:5,time:1000});
				}
			}
		});
	});
}
</script>